package cn.wolfcode.luowowo.shop.service.impl;

import cn.wolfcode.luowowo.shop.domain.ShopContent;
import cn.wolfcode.luowowo.shop.domain.ShopDetail;
import cn.wolfcode.luowowo.shop.domain.ShopRoll;
import cn.wolfcode.luowowo.shop.domain.ShopStrategy;
import cn.wolfcode.luowowo.shop.mapper.ShopContentMapper;
import cn.wolfcode.luowowo.shop.mapper.ShopDetailMapper;
import cn.wolfcode.luowowo.shop.query.ShopDetailQuery;
import cn.wolfcode.luowowo.shop.service.IShopDetailService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ShopDetailServiceImpl implements IShopDetailService {
    @Autowired
    private ShopDetailMapper shopDetailMapper;
    @Autowired
    private ShopContentMapper shopContentMapper;
//分页
    @Override
    public PageInfo query(ShopDetailQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<ShopDetail> list = shopDetailMapper.selectAll();
        return new PageInfo(list);
    }

  //窝窝周边前三
    @Override
    public List<ShopDetail> getTop3() {
        return shopDetailMapper.getTOP3();
    }
    //找所有商品
    @Override
    public List<ShopDetail> list() {

        return shopDetailMapper.selectAll();
    }
    //通过id找商品
    @Override
    public ShopDetail selectByDetailId(Long id) {
        ShopContent content = shopContentMapper.selectById(id);

        ShopDetail detail = shopDetailMapper.selectByPrimaryKey(id);
        detail.setShopContent(content);

        return detail;
    }


    @Override
    public void saveOrUpdate(ShopDetail shopDetail) {

    }

    @Override
    public void delete(Long id) {

    }
}